package com.lysj.print.print.repository;

import com.lysj.admin.utils.spring.foundation.base.BaseRepository;
import com.lysj.admin.utils.web.SelectItem;
import com.lysj.print.print.domain.Printer;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * @author Created by drj on 2019-03-15 16:40:54
 * @description 打印机dao
 */
public interface PrinterRepository extends BaseRepository<Printer> {

    //获取对应门店打印机列表
    Page<Printer> findByStoreIdAndDelFlag(Pageable pageable, String storeId, Integer deflag);

    //获取门店默认打印机
    Printer findByStoreIdAndIsDefaultAndDelFlag(String storeId, Integer isDefault, Integer deflag);

    //获取对应门店打印机下拉框
    @Query("SELECT  NEW com.lysj.admin.utils.web.SelectItem(p.id AS value,p.name AS name) from Printer p where p.storeId=?1 AND p.delFlag=1")
    List<SelectItem> selectItems(String storeId);

}